//安装jwt
var jsonwebtoken = require("jsonwebtoken");
var tokenKeyboards = "haggurg1";
Token = {
  //加密token
  en(str) {
    let token = jsonwebtoken.sign(str, tokenKeyboards);
    return token;
  },
  //解密token
  de(token) {
    try {
      let key = jsonwebtoken.verify(token, tokenKeyboards);
      return {
        status: "success",
        key,
      };
    } catch {
      return {
        status: "faile",
      };
    }
  },
};
module.exports = Token;
